﻿Imports Microsoft.Practices.Composite.Regions
Imports Infragistics.Windows.Ribbon
Imports Infragistics.Windows.DockManager


Namespace Services


    Public Class ContentService
        Implements IContentService






        Private ReadOnly m_regionManager As IRegionManager

        Public Sub New(ByVal regionManager As IRegionManager)
            m_regionManager = regionManager
        End Sub

        Public Sub EnsureBaseRegions() Implements IContentService.EnsureBaseRegions
            RegisterSplitPaneRegion(RegionNames.Shell_DockManager_DocumentSplitPane_Main, RegionNames.Shell_DockManager_DocumentSplitPanes)
            RegisterTabGroupPaneRegion(RegionNames.Shell_DockManager_DocumentSplitPane_MainTabGroup, RegionNames.Shell_DockManager_DocumentSplitPane_Main)
        End Sub

        Public Sub RegisterContentPaneRegion(ByVal newRegionName As String, ByVal Caption As String, ByVal addToRegionName As String) Implements IContentService.RegisterContentPaneRegion
            If Not m_regionManager.Regions.ContainsKey(newRegionName) Then
                'Get the ribbon region
                Dim region As IRegion = m_regionManager.Regions(addToRegionName)

                Dim thing As New ContentPane
                thing.Header = Caption

                ' Add View
                region.Add(thing)
                ' Defign the inner region
                m_regionManager.AttachNewRegion(thing, newRegionName)

            End If
        End Sub

        Public Sub RegisterSplitPaneRegion(ByVal newRegionName As String, ByVal addToRegionName As String) Implements IContentService.RegisterSplitPaneRegion
            If Not m_regionManager.Regions.ContainsKey(newRegionName) Then
                'Get the ribbon region
                Dim region As IRegion = m_regionManager.Regions(addToRegionName)

                Dim thing As New SplitPane

                ' Add View
                region.Add(thing)
                ' Defign the inner region
                m_regionManager.AttachNewRegion(thing, newRegionName)

            End If
        End Sub

        Public Sub RegisterTabGroupPaneRegion(ByVal newRegionName As String, ByVal addToRegionName As String) Implements IContentService.RegisterTabGroupPaneRegion
            If Not m_regionManager.Regions.ContainsKey(newRegionName) Then
                'Get the ribbon region
                Dim region As IRegion = m_regionManager.Regions(addToRegionName)

                Dim thing As New TabGroupPane

                ' Add View
                region.Add(thing)
                ' Defign the inner region
                m_regionManager.AttachNewRegion(thing, newRegionName)

            End If
        End Sub


    End Class

End Namespace